<ion-header>
    <ion-navbar core-back-button>
        <ion-title>{{ 'core.login.login' | translate }}</ion-title>

        <ion-buttons end>
            <button *ngIf="isFixedUrlSet" ion-button icon-only [navPush]="'CoreSettingsListPage'" [attr.aria-label]="'core.mainmenu.appsettings' | translate">
                <ion-icon name="cog"></ion-icon>
            </button>
        </ion-buttons>
    </ion-navbar>
</ion-header>
<ion-content class="core-center-view">
    <core-loading [hideUntil]="pageLoaded">
        <div class="box">
            <div text-wrap text-center margin-bottom>
                <!-- Show site logo or a default image. -->
                <img *ngIf="logoUrl" [src]="logoUrl" role="presentation">
                <img *ngIf="!logoUrl" src="assets/img/login_logo.png" class="login-logo" role="presentation">

                <!-- If no sitename show big siteurl. -->
                <p *ngIf="!siteName" padding class="item-heading core-siteurl">{{siteUrl}}</p>
                <!-- If sitename, show big sitename and small siteurl. -->
                <p *ngIf="siteName" padding class="item-heading core-sitename"><core-format-text [text]="siteName" [filter]="false"></core-format-text></p>
                <p *ngIf="siteName" class="core-siteurl">{{siteUrl}}</p>
            </div>
            <form ion-list [formGroup]="credForm" (ngSubmit)="login($event)" class="core-login-form">
                <ion-item *ngIf="siteChecked && !isBrowserSSO">
                    <ion-input type="text" name="username" placeholder="{{ 'core.login.username' | translate }}" formControlName="username" autocapitalize="none" autocorrect="off"></ion-input>
                </ion-item>
                <ion-item *ngIf="siteChecked && !isBrowserSSO" margin-bottom>
                    <core-show-password item-content [name]="'password'">
                        <ion-input class="core-ioninput-password" name="password" type="password" placeholder="{{ 'core.login.password' | translate }}" formControlName="password" core-show-password [clearOnEdit]="false"></ion-input>
                    </core-show-password>
                </ion-item>
                <button ion-button block [disabled]="siteChecked && !isBrowserSSO && !credForm.valid">{{ 'core.login.loginbutton' | translate }}</button>
            </form>

            <!-- Forgotten password button. -->
            <div *ngIf="showForgottenPassword" padding-top class="core-login-forgotten-password">
                <button ion-button block text-wrap color="light" (click)="forgottenPassword()">{{ 'core.login.forgotten' | translate }}</button>
            </div>

            <ion-list *ngIf="identityProviders && identityProviders.length" padding-top class="core-login-identity-providers">
                <ion-list-header text-wrap>{{ 'core.login.potentialidps' | translate }}</ion-list-header>
                <button ion-item *ngFor="let provider of identityProviders" text-wrap class="core-oauth-icon" (click)="oauthClicked(provider)" title="{{provider.name}}">
                    <img [src]="provider.iconurl" alt="" width="32" height="32" item-start>
                    {{provider.name}}
                </button>
            </ion-list>

            <ion-list *ngIf="canSignup" padding-top class="core-login-sign-up">
                <ion-list-header text-wrap>{{ 'core.login.firsttime' | translate }}</ion-list-header>
                <ion-item no-lines text-wrap *ngIf="authInstructions">
                    <p><core-format-text [text]="authInstructions" [filter]="false"></core-format-text></p>
                </ion-item>
                <button ion-button block (click)="signup()">{{ 'core.login.startsignup' | translate }}</button>
            </ion-list>
        </div>
    </core-loading>
</ion-content>
